import Vue from 'vue'
import VueRouter from 'vue-router'
// 错误页面
import others from '@/components/HelloWorld'
//主页
import Home from '../components/Home'
// 推荐
import Recommended from '../components/Recommended'
// 标签
import Lable from '@/components/lable/Lable'

// 流通
import Logistics from '../components/Logistics'
// 藏书
import Collection from '../components/Collection'
// 我的
import Center from '../components/Center'
// 我的书包
import Package from '@/components/center/Package'
// 我的订单
import MyOrder from '@/components/center/MyOrder'
// 新手指南
import guide from '@/components/center/guide'
// 搜索
import Search from '@/components/public/Search'
// 图书详情
import BookInfo from '@/components/public/BookInfo'

window.eventBus = new Vue();
//注册VueRouter这个插件
Vue.use(VueRouter)
  const router =[
    {path: '/', name: 'Home',redirect: '/recommended',component: Home,
      children: [
            {path: '/recommended',name:'Recommended',component: Recommended,},
            {path: '/logistics',name:'Logistics',component: Logistics, },        
            {path: '/collection',name:'Collection',component: Collection, },        
            {path: '/center',name:'Center',component: Center,},
        ]
    },   
    {path: '/lable',name:'Lable',component: Lable,},    
    {path: '/search',name:'Search',component: Search,},
    {path: '/bookinfo',name:'BookInfo',component: BookInfo,},   
    {path: '/package',name:'Package',component: Package,}, 
    {path: '/myorder',name:'MyOrder',component: MyOrder,},
    {path: '/guide',name:'guide',component: guide,},
    
    
    //错误页面
    {path: '*',name: 'others',redirect: '/others',component: others} 
  ];
  const VRouters = new VueRouter({
    routes: router,
  })
//   VRouters.beforeEach((to, from, next) => {
//     next();
//   })

export default VRouters


